﻿
function CreateEditor(textBoxId, enterPostButtonID) {
    CreateEditorByMode(textBoxId, "Full");
}
function CreateEditoAuto(textBoxId, enterPostButtonID, mode) {

    CreateEditorByMode(textBoxId, mode);
}
function CreateEditorByMode(textBoxId, modeType) {

    var menus = getMode(modeType);
     
    var uploadImgJSon=$("#"+textBoxId).attr("uploadImageJson")||"upload_json.jsp";
   
    //加载Html编辑器 
    KE.show({
        id: textBoxId,
        allowFileManager: true,
        imageUploadJson:uploadImgJSon,
    	fileManagerJson : 'file_manager_json.jsp',
        resizeMode: 1,
       // items: menus,
        afterCreate: function (id) {
            KE.event.ctrl(document, 13, function () {
                KE.util.setData(id);
            });
            KE.event.ctrl(KE.g[id].iframeDoc, 13, function () {
                KE.util.setData(id);
            });
        }
    });
}

function initializeTextEditor() {
    $(".ui-text-editor").each(function (i) {
        var textBoxId = $(this).attr("id");
        var mode = $(this).attr("mode");

        CreateEditoAuto(textBoxId, "", mode);
    });
}
$(function () {
    initializeTextEditor();
});



function getMode(type) {
    if (type == "Simple") {
        return [
                'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
                'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                'insertunorderedlist'];
    }
    else
        return [
                'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
                'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                'insertunorderedlist', '|', 'emoticons', 'image', 'link'];
}
 
